import Vue from 'vue'
import VueRouter from 'vue-router'

//路由懒加载
const home = () => import('views/home/Home.vue')
const buy = () => import('views/buy/Buy.vue')
const detail = () => import('views/buyDetail/detail.vue')
const cart = () => import('views/cart/Cart.vue')
const me = () => import('views/me/Me.vue')
const location = () => import('views/location/Location.vue')
 
Vue.use(VueRouter)

const routes=[
  {
    path:'/',
    redirect:'/home'
  },
  {
    path:'/home',
    component:home
  },
  {
    path:'/buy',
    component:buy
  },
  {
    path:'/detail',
    component:detail
  },
  {
    path:'/cart',
    component:cart
  },
  {
    path:'/me',
    component:me
  },
  {
    path:'/location',
    component:location
  }
]
const router = new VueRouter({
  routes,
  mode: "history"
})


const originalReplace = VueRouter.prototype.replace;
VueRouter.prototype.replace = function replace(location) {
  return originalReplace.call(this, location).catch(err => err);
}

export default router